﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DeviceDemo
{
    /// <summary>
    /// 消息队列,此处只以某工序为例。
    /// 如果一个项目里有多道工序，建议每个工序都用独立的队列 
    /// </summary>
    internal class DataQueue
    {
        private static object locker=new object();
        static Queue<DeviceReceiveData> queue=new Queue<DeviceReceiveData>();


        public static void Push(DeviceReceiveData item)
        {
            lock (locker)
            {
                queue.Enqueue(item);
            }
        }

        public static DeviceReceiveData? Pop()
        {
            lock (locker)
            {
                if (queue.Count == 0)
                {
                    return null;
                }
                var item = queue.Dequeue();
                return item;
            } 
        }


    }



}
